function getCaculatedDate(iYear, iMonth, iDay, seperator) {
	var gdCurDate = new Date();
	gdCurDate.setYear(gdCurDate.getFullYear() + iYear);
	gdCurDate.setMonth(gdCurDate.getMonth() + iMonth);
	gdCurDate.setDate(gdCurDate.getDate() + iDay);

	var giYear = gdCurDate.getFullYear();
	var giMonth = gdCurDate.getMonth() + 1;
	var giDay = gdCurDate.getDate();

	giMonth = "0" + giMonth;
	giMonth = giMonth.substring(giMonth.length-2,giMonth.length);
	giDay = "0" + giDay;
	giDay = giDay.substring(giDay.length-2,giDay.length);

	return giYear + seperator + giMonth + seperator + giDay;
}


function onToday(on1, on2) {
	var input1 = document.getElementById(on1);
	var input2 = document.getElementById(on2);

	var date = new Date();
	var day = date.getDate();
	var month = date.getMonth() +1;

	if (day <10)
	{
		day = "0"+day;
	}

	if (month <10)
	{
		month = "0"+month;
	}
	input1.value = date.getFullYear() + "-" + month + "-" + day;
	input2.value = date.getFullYear() + "-" + month + "-" + day;
}

function onWeek(on1, on2) {
	var input1 = document.getElementById(on1);
	var input2 = document.getElementById(on2);

	var date = new Date();
	var startDate = getCaculatedDate(0,0,-6,"-");

	var day = date.getDate();
	var month = date.getMonth() +1;

	if (day <10)
	{
		day = "0"+day;
	}

	if (month <10)
	{
		month = "0"+month;
	}

	input1.value = startDate;
	input2.value = date.getFullYear() + "-" + month + "-" + day;
}

function onMoth(on1, on2) {
	var input1 = document.getElementById(on1);
	var input2 = document.getElementById(on2);

	var date = new Date();
	var startDate = getCaculatedDate(0,-1,1,"-");

	var day = date.getDate();
	var month = date.getMonth() +1;

	if (day <10)
	{
		day = "0"+day;
	}

	if (month <10)
	{
		month = "0"+month;
	}

	input1.value = startDate;
	input2.value = date.getFullYear() + "-" + month + "-" + day;
}

function on2Month(on1, on2) {
	
	var input1 = document.getElementById(on1);
	var input2 = document.getElementById(on2);

	var date = new Date();
	var startDate = getCaculatedDate(0,-2,1,"-");

	var day = date.getDate();
	var month = date.getMonth() +1;

	if (day <10)
	{
		day = "0"+day;
	}

	if (month <10)
	{
		month = "0"+month;
	}

	input1.value = startDate;
	input2.value = date.getFullYear() + "-" + month + "-" + day;
}

function onAll(on1, on2) {
	var input1 = document.getElementById(on1);
	var input2 = document.getElementById(on2);

	var date = new Date();
	var day = date.getDate();
	var month = date.getMonth() +1;

	if (day <10)
	{
		day = "0"+day;
	}

	if (month <10)
	{
		month = "0"+month;
	}

	input1.value = "2012-03-01";
	input2.value = date.getFullYear() + "-" + month + "-" + day;
}